route.ts 626 B

12345678910111213141516171819202122232425
  1. import { NextResponse } from "next/server";
  2. import { loadAgentFeed } from "@/lib/agent-monitor";
  3. type AgentRouteProps = {
  4. params: Promise<{
  5. agentId: string;
  6. }>;
  7. };
  8. export async function GET(_: Request, { params }: AgentRouteProps) {
  9. const { agentId } = await params;
  10. const feed = await loadAgentFeed("all");
  11. const agent = feed.agents.find((item) => item.id === agentId);
  12. if (!agent) {
  13. return NextResponse.json({ message: "Agent not found" }, { status: 404 });
  14. }
  15. return NextResponse.json({
  16. source: feed.source,
  17. sourceLabel: feed.sourceLabel,
  18. fetchedAt: feed.fetchedAt,
  19. agent
  20. });
  21. }